package com.edu.exam.enums.assessment;


/**
 * 任务分配状态枚举
 * 统一管理任务分配的状态定义
 *
 * @author System
 * @version 1.0.0
 */
public enum TaskAssignmentStatus {

    ASSIGNED("ASSIGNED", "已分配"),
    NOT_STARTED("NOT_STARTED", "未开始"),
    IN_PROGRESS("IN_PROGRESS", "进行中"),
    PAUSED("PAUSED", "已暂停"),
    SUBMITTED("SUBMITTED", "已提交"),
    BEING_GRADED("BEING_GRADED", "正在评分"),
    GRADED("GRADED", "已评分"),
    REVIEWED("REVIEWED", "已复审"),
    COMPLETED("COMPLETED", "已完成"),
    EXPIRED("EXPIRED", "已过期"),
    CANCELLED("CANCELLED", "已取消"),
    FAILED("FAILED", "考试失败"),
    CHEATING("CHEATING", "作弊");

    private final String code;
    private final String description;

    TaskAssignmentStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static TaskAssignmentStatus fromCode(String code) {
        if (code == null || code.trim().isEmpty()) {
            return null;
        }

        for (TaskAssignmentStatus value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }
}